﻿using UnityEngine;
using Game.Kernel;
using Game.Logic.Events;

namespace UIFramework
{
    public abstract class GameUIView : GameBaseView
    {
        protected CanvasGroup canvasGroup;
        protected CanvasGroup CanvasGroup
        {
            get
            {
                if (null == canvasGroup)
                {
                    canvasGroup = gameObject.AddComponent<CanvasGroup>();
                }
                return canvasGroup;
            }
        }

        public GameUIEvent GameUIEnterEvent { protected set; get; }
        public GameUIEvent GameUIResumeEvent { protected set; get; }
        public GameUIEvent GameUIPauseEvent { protected set; get; }
        public GameUIEvent GameUIExitEvent { protected set; get; }
        protected virtual void RegisterGameUIEvent() {}

        // UI链接完成时调用
        public virtual void OnLink() {}

        // UI断开链接时调用
        public virtual void OnUnlink() {}

        // UI进入时调用
        public abstract void OnEnter(params object[] _params);

        // UI显示时调用
        public abstract void OnResume();

        // UI隐藏时调用
        public abstract void OnPause();

        // UI释放时调用
        public abstract void OnExit();
    }

}
